package com.test.selenium.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;

import com.test.selenium.AirSmokeTest;
import com.test.selenium.data.Results;

public class ManualInput {
	private boolean debugMode;
	 private String productGroup;
     private String payer;
     private String billingSite;
     //private String ItemNbr;
     //private String ItemDate ;
     private String product ;
	
     private String chargecode2;
     private String basis;
     private String amount;
     private String currency;
    
     public ManualInput(){};
 	public  void readManualInput(){
 		String isPass = "PASS";
		String testTimeTakenSec = "0";
 		try
 		{
 		
 		FileInputStream file;
 		file = new FileInputStream(new File("../selenium/src/Input/SmokeTestManualInvoice_InputSheet.xls"));
 		HSSFWorkbook workbook = new HSSFWorkbook(file);
 		HSSFSheet inputSheet = workbook.getSheetAt(0);
 		Row row = inputSheet.getRow(1);
 		
 	/*	Iterator rows = inputSheet.rowIterator(); 
 		while( rows.hasNext() ) 
 			{ 
 			HSSFRow row = (HSSFRow) rows.next();
 			System.out.println("\n");
 			Iterator cells = row.cellIterator(); 
 			while( cells.hasNext() ) 
 			{ 
 				HSSFCell cell = (HSSFCell) cells.next(); 
 				if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType())
 					cell.getNumericCellValue(); 
 				 if(HSSFCell.CELL_TYPE_STRING==cell.getCellType()) 
 					 cell.getStringCellValue(); 
 				 if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType()) 
 					cell.getBooleanCellValue(); 
 				 if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType()) 
 					 System.out.print("Unknown cell type");
 			}
 			}
 */
 		
 		
 		
 		
 		//Manual Invoice
 		productGroup = row.getCell(0).getStringCellValue().trim();
 		payer = row.getCell(1).getStringCellValue().trim();
 		billingSite = row.getCell(2).getStringCellValue().trim();
 		product = row.getCell(3).getStringCellValue().trim();
 		
 		//Manual Invoice charges
 		chargecode2 = row.getCell(4).getStringCellValue().trim();
 		basis = row.getCell(5).getStringCellValue().trim();
 		amount = row.getCell(6).getStringCellValue().trim();
 		currency = row.getCell(7).getStringCellValue().trim();
 		
 		if (debugMode) {
			//Manual Inovice
			System.out.println("ProductGroup: " + productGroup);
			System.out.println("Payer: " + payer);
			System.out.println("billingSite: " + billingSite);
			System.out.println("product: " + product);
			System.out.println("chargecode2: " + chargecode2);
			System.out.println("basis: " + basis);
			System.out.println("amount: " + amount);
			
			System.out.println("currency: " + currency);
			
 		}	
		file.close();
 		}
		catch (Exception e) {
        	e.printStackTrace();
        	if (e instanceof InterruptedException) {
        		// Currently ignore exception thrown by "Thread.sleep"
        	}
        	else {
        		// Other exceptions such as certain element not found considered as fail.
        		isPass = "FAIL";
        	}
        
		AirSmokeTest.RESULT_ARRAY.add(new Results("Freight", "AssignContainerToMovement", isPass, "N/A", testTimeTakenSec));
 	}	
 	}
 	     

public String getProductGroup() {
	return this.productGroup;
}

public String getPayer() {
	return this.payer;
}

public String getBillingSite() {
	return this.billingSite;
}	

public String getProduct() {
	return this.product;
}
public String getChargecode2() {
	return this.chargecode2;
}
public String getBasis() {
	return this.basis;
}
public String getAmount() {
	return this.amount;
	}

public String getCurrency() {
	return this.currency;
	
}
}